#!/bin/bash


if [ -f /root/.ssh/id_rsa  ]; then
   rm -rf /root/.ssh/id_rsa
fi
ssh-keygen -t rsa -f "/root/.ssh/id_rsa" -P "" &>/dev/null

for i in 12; do
/usr/bin/expect << eof
set timeout 10
spawn ssh-copy-id root@192.168.2.$i
expect "(yes/no)?"
send "yes\n"
expect "password:"
send "123\n"
expect eof 
eof
done

for i in 12; do 
   ssh root@192.168.2.$i hostname;date
done
